package sk.stuba.fiit.repka.dp.main;

import java.awt.EventQueue;
import java.sql.SQLException;

import org.apache.log4j.Logger;

import sk.stuba.fiit.repka.dp.db.DatabaseController;
import sk.stuba.fiit.repka.dp.gui.MainWindow;
import sk.stuba.fiit.repka.dp.gui.SplashWindow;

/**
 * 
 * @author Igor Repka
 *
 */
public class Launcher {
	private static Logger logger = Logger.getLogger(Launcher.class);
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		SplashWindow splash = new SplashWindow(5000);
		
		//connect to DB
		final DatabaseController dbController = new DatabaseController();
		try {
			dbController.createConnection();
		} catch (SQLException e1) {
			logger.error("Error occured during connecting to database!");
			e1.printStackTrace();
		}
		
		//run GUI
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					new MainWindow(dbController);
				} catch (Exception e) {
					logger.error("Error occuderd during GUI initializing");
					e.printStackTrace();
				}
			}
		});
	}

}
